package com.yh.rent.entity;

import java.sql.Date;

import javax.persistence.*;

import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

/**
 * 
 * �������� �ⷿϵͳ�ķ��ݱ�  
 *  
 * @author: Administrator  
 * @date�� 2017-10-31 3:09:22 PM  
 * @version 1.0
 */
@Entity
@Table(name = "house")
public class House {
	private Integer id ;
	/*private Integer userId ;
	private Integer streetId ;
	private Integer typeId;*/
	private String title ;//�������ⷿ��Ϣ�ı���
	private String description ; //ס������
	private Double price ; //���ݼ۸�
	private Date pubdate ;//����ʱ��
	private Double floorage ; //�������
	private String contact ; //��ϵ��ʽ
	private Type type ; //一种类型对应多个房屋
	private User user ;//一个用户对应多个房屋
	private Street street ; //一个房屋对应一个街道
	
/*	@Column(name="use_id")
	public Integer getUserId() {
		return userId;
	}
	public void setUserId(Integer userId) {
		this.userId = userId;
	}
	@Column(name="street_id")
	public Integer getStreetId() {
		return streetId;
	}
	public void setStreetId(Integer streetId) {
		this.streetId = streetId;
	}
	@Column(name="type_id")
	public Integer getTypeId() {
		return typeId;
	}
	public void setTypeId(Integer typeId) {
		this.typeId = typeId;
	}*/
	@ManyToOne(cascade=CascadeType.ALL)
	@JoinColumn(name="street_id")
	public Street getStreet() {
		return street;
	}
	public void setStreet(Street street) {
		this.street = street;
	}
	@ManyToOne(cascade=CascadeType.ALL)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name="user_id")
	public User getUser() {
		return user;
	}
	public void setUser(User user) {
		this.user = user;
	}
	@ManyToOne(cascade=CascadeType.ALL)
	@Fetch(FetchMode.JOIN)
	@JoinColumn(name = "type_id")
	public Type getType() {
		return type;
	}
	public void setType(Type type) {
		this.type = type;
	}
	@Id
	@GeneratedValue(strategy = GenerationType.SEQUENCE , generator = "mygenerator")
	@SequenceGenerator(name = "mygenerator", sequenceName = "house_seq", initialValue = 1 , allocationSize = 1)
	public Integer getId() {
		return id;
	}
	public void setId(Integer id) {
		this.id = id;
	}
	@Column(name = "title")
	public String getTitle() {
		return title;
	}
	public void setTitle(String title) {
		this.title = title;
	}
	@Column(name = "description")
	public String getDescription() {
		return description;
	}
	public void setDescription(String description) {
		this.description = description;
	}
	@Column(name = "price")
	public Double getPrice() {
		return price;
	}
	public void setPrice(Double price) {
		this.price = price;
	}
	@Column(name = "pubdate")
	public Date getPubdate() {
		return pubdate;
	}
	public void setPubdate(Date pubdate) {
		this.pubdate = pubdate;
	}
	@Column(name = "floorage")
	public Double getFloorage() {
		return floorage;
	}
	public void setFloorage(Double floorage) {
		this.floorage = floorage;
	}
	@Column(name = "contact")
	public String getContact() {
		return contact;
	}
	public void setContact(String contact) {
		this.contact = contact;
	}
	@Override
	public String toString() {
		return "House [id=" + id + ", title=" + title + ", description=" + description + ", price=" + price
				+ ", pubdate=" + pubdate + ", floorage=" + floorage + ", contact=" + contact + ", type=" + type
				+ ", user=" + user + ", street=" + street + "]";
	}	
	
}
